<?php

class StateAction extends ActionBase {
	public $modelName;
	public $nextState;
	public $stateHandle = 'stateHandle';
	
	public function run($id) {
		$c = $this->controller;
		$modelName = $this->modelName;
		$model = $c->loadModel($id);
		$model->{$this->stateHandle}->setState($this->nextState);
		if($model->getErrors()) {
			Yii::app()->user->setFlash(FLASH::RESULT_FAILED, CHtml::errorSummary($model));
		}
		$this->controller->redirect(array('admin'));
	}
	
}

?>